<template>
  <div class="top-search-div">
    <div class="top-search">

      <router-link
        :to="lSrc?lSrc:''"
        tag='div'
        class="top-location"
      >
        <img :src="lUrl" />
        <span>{{lText}}</span>
      </router-link>

      <router-link
        tag="div"
        to="/search"
        class="input-div"
      >
        <img src="../assets/img/search.png" />
        <input :placeholder="placeholder"/>
      </router-link>

      <router-link
        v-if="hasLogin"
        tag="div"
        class="top-right"
        to="/cart"
      >
        <img src="../assets/img/home/shoppingCar.png" />
        <span class="tip-num">{{cartNum}}</span>
      </router-link>
      <router-link
        v-else
        tag="div"
        class="top-right"
        :to="{path:'/login',query:{backUrl:backUrl}}"
      >
        <img src="../assets/img/home/shoppingCar.png" />
      </router-link>
    </div>
  </div>
</template>

<script>
export default {
  name: 'top-search',
  props: ['placeholder', 'lSrc', 'lText', 'lUrl', 'cartNum'],
  components: {},
  data() {
    return {
      title: '',
      backUrl: document.location.href
    }
  },
  methods: {
    // back: function () {
    //     this.$router.go(-1);
    // }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">
.top-search-div {
  position: relative;
  height: 92px;
  color: white;
  font-size: 36px;
  text-align: center;
}
.top-search {
  max-width: 800px;
  background: #03a9f4;
  height: 92px;
  line-height: 92px;
  position: fixed;
  width: 100%;
  z-index: 100;
  display: flex;
  display: -webkit-flex;
  /*top: 0;*/
}
.top-search .input-div {
  height: 92px;
  flex: 1;
  -webkit-box-flex: 1;
  /*width: 55%;*/
  margin: auto;
  line-height: 92px;
  border-radius: 60px;
  position: relative;
  top: -2px;
}
.input-div input {
  width: 100%;
  height: 62px;
  line-height: 62px;
  border-radius: 6px;
  border: none;
  font-size: 28px;
  padding: 0 10px;
}
.input-div img {
  position: absolute;
  right: -10px;
  top: 30px;
  width: 34px;
}
.top-location {
  /*position: absolute;*/
  padding: 0 20px;
  height: 92px;
  min-width: 60px;
}
.top-location img {
  width: 28px;
  position: relative;
  top: 10px;
}
.top-right {
  /*position: absolute;*/
  width: 58px;
  right: 0;
  top: 0;
  padding-right: 30px;
  padding-left: 50px;
  padding-top: 10px;
  height: 70px;
}
.top-right img {
  width: 56px;
}
.tip-num {
  width: auto;
  height: 26px;
  display: inline-block;
  background: #f23030;
  color: white;
  position: absolute;
  top: 10px;
  right: 20px;
  line-height: 26px;
  border-radius: 26px;
  font-weight: bold;
  font-size: 24px;
  padding: 0 8px;
}
</style>
